from pattern.circuit import Control

class entry(Control):
    
    def incoming(self, event):
        page = self.collect(event)
        event.trail.send_response(200)
        event.trail.send_header("Content-type", "text/html")
        event.trail.send_header("Content-length", str(len(page)))
        event.trail.end_headers()
        event.trail.wfile.write(page)
        
    def collect(self, event):
        bridge = self.acquireInterface(event, "Dynamic")
        if bridge is not None:
            return bridge.pull()
        else:
            return ""
